import reqeust from "@/utils/request";

export interface typeLoginType {
  token: string;
}
export interface typeRegisterType {
  username: string,
  password: string,
  email: string,
  phone: string,
  photo: string,
  _id: string,
  createdAt: string,
  updatedAt: string,
  __v: number
}
export interface typeUserInfo {
  _id: string;
  username: string;
  email: string;
  photo: string;
  createdAt?: string;
}



export default {
  //用户登录请求
  reqeustLogin: ({ email, password }: { email: string; password: string }) => {
    return reqeust.post<any, typeLoginType>("user/login", { email, password });
  },
  //获取用户信息
  reqeustUserInfo: () => {
    return reqeust.get<any, typeUserInfo>("/user/verifyToken");
  },
  //用户注册请求
  reqeustRegister: ({ username, password, email, phone }: { username: string, phone: string, email: string, password: string }) => {
    return reqeust.post<any, typeRegisterType>("user/register", { phone, username, email, password })
  }
};
